package SwingView.Message;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import JDBC.InstructorAnnouncementActivities;
import JDBC.MessageActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsInstructor;
import SwingModel.CmsMessage;
import SwingModel.CmsUser;
import SwingView.CmsMainView;
import SwingView.CmsPageSelector.CmsPage;

public class ALMessage implements ActionListener{

	private final CmsMainView mainView;
	private final CmsUser user;
	private final CmsCPMessage messagePage;

	//---------------------------------------------------------
	//CONSTRUCTOR:
	//---------------------------------------------------------		
	public ALMessage(CmsMainView mainView, CmsUser user){
		this.mainView = mainView;
		this.user = user;
		this.messagePage = mainView.getContentPanel().getMessagePage();
	}

	//---------------------------------------------------------
	//PERFORMING ACTION:
	//---------------------------------------------------------		
	@Override
	public void actionPerformed(ActionEvent e){
		
		List<CmsMessage> listOfMessage = null;
		
		listOfMessage = MessageActivities.getListOfMessage(CmsPresenter.user.getUsername()
				, CmsPresenter.user.getSelectedCourse().getCourseID());
		
		//Set Page View the People Button
		mainView.displayMessagePage(listOfMessage);;
	}
}
